const path = require('path')
const { override, addWebpackAlias, addPostcssPlugins } = require('customize-cra')
const px2viewport = require('postcss-px-to-viewport')

const webpackAlias = addWebpackAlias({
  '@': path.resolve(__dirname, 'src'),
})

// 配置 PostCSS 样式转换插件
const postcssPlugins = addPostcssPlugins([
  // 移动端布局 viewport 适配方案
  px2viewport({
    // 视口宽度
    viewportWidth: 375,
  }),
])

// 导出要进行覆盖的 webpack 配置
module.exports = override(webpackAlias, postcssPlugins)